<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>管理平台</title>
<jsp:include page="../../include/header.jsp"></jsp:include>
</head>
<body>
	<div id="wrapper">
		
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">设置商品</h1>
				</div>
			</div>


			<div class="row">
				<div class="col-lg-12">
					<div class="row">
						<div class="col-lg-6">
							<div class="text-muted single-line-text pull-left">
								<!-- 共 <font color="#428bca" id="dataCount">0</font> 条记录 -->
								<h2>数据列表</h2>
							</div>
						</div>
						<div class="pull-right">
								<input type="button" onclick="javascript:window.location.reload()" value="刷新"/>
						</div>						
					</div>
					
					<div class="table-responsive">
						<table id="dataTable" class="table table-striped table-hover">
							<thead>
								<tr>
									<th>编号</th>
									<th>秒杀时段名称</th>
									<th>每日开始时间</th>
									<th>每日结束时间</th>
									<th>商品数量</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody id="dataList"></tbody>
						</table>
					</div>
					<div class="row">
						<div class="col-lg-12">
							<ul id="dataPagination" class="pagination-sm pull-right"></ul>
						</div>
					</div>
				</div>
			</div>
		
	</div>
	<!-- <td><button type="button" class="btn btn-sm btn-primary btn-simple" onclick="tolist('{{item.id}}')" title="商品列表"></button></td> -->
	<jsp:include page="../../include/javascripts.jsp"></jsp:include>
	<!-- 异步加载下一页数据后，用模板渲染 -->
	<script type="text/html" id="dataTpl">
	{{each list as item}}
	<tr id="item{{item.id}}" data-id="{{item.id}}">
		<td>{{item.id}}</td>
		<td>{{item.time_line}}</td>
		<td>{{item.begin}}</td>
		<td>{{item.end }}</td>
		<td>{{item.tu }}</td>
		
		<td><button type="button" class="btn btn-success" onclick="toList('{{item.id}}')" title="商品列表"><span>商品列表</span></button>
</td>
	</tr>
	{{/each}}
</script>
	<script type="text/javascript">

		var dataPaginator;
		$(function() {
			dataPaginator = Kit.pagination("#dataPagination",
					"${BASE_PATH}/spike/list/pageList", {
						"pageSize" : 10
					}, function(result) {
						//设置显示最新的数据数量
						$("#dataCount").html(result.object.totalRow);
						//根据模板渲染数据并填充
						$("#dataList").empty().append(
								template("dataTpl", result.object));
					});
		});

		var addDialog;
		function toAdd() {
			addDialog = Kit.dialog("添加商品", "${BASE_PATH}/spike/setgoods/toAdd")
					.open();
		}
		//通过直接跳转get方式传参数
		function toList(){
			window.location.href="${BASE_PATH}/spike/list/toList?id="+id;
			
		}
		
		//通过post方式传参数
		function toSet(url, id) {
			url = "${BASE_PATH}/spike/list/toList";
			var form = $("<form method='post'>");
			form.attr({
				"action" : url
			});
			for (arg in id) {
				var input = $("<input type='hidden'>");
				input.attr({
					"name" : arg
				});
				input.val(args[arg]);
				form.append(input);
			}
			$("html").append(form);
			form.submit();
		}

		function toDeleteGoods(id) {
			Kit.confirm("提示", "您确定要删除这条数据吗？", function() {
				$.post("${BASE_PATH}/spike/list/doDeleteGoods/" + id, function(
						result) {
					$("#item" + id).remove();
				});
			});
		}
		function doSort() {
			$("#sortForm").ajaxSubmit({
				success : function(data) {
					switch (data.flag) {
					case -1:
						Kit.alert("网络繁忙...，请重试");
						return;
					case 0:
						window.location.reload();
					}
				}
			});
		}
	</script>
</body>
</html>